package com.jiangyifen.robot.websocket;

import com.jiangyifen.robot.websocket.internal.WebsocketCache;
import com.jiangyifen.robot.websocket.internal.WebsocketMessage;
import com.jiangyifen.robot.websocket.internal.WebsocketMessageRunnable;

/**
 * 这个class都是static函数，不需要被new，可以直接使用
 * @author 江毅奋
 * @email jiangyifen@icloud.com
 *
 */
public class WebsocketUtil {

	/**
	 * 将需要发送的消息放入消息队列<br/>
	 * 放入失败会抛出java.util.concurrent.RejectedExecutionException
	 * 
	 * @param clientId
	 * @param msg
	 * @return
	 */
	public static void unicast(String clientId, String msg) {
		WebsocketMessage message = new WebsocketMessage(msg, clientId);
		WebsocketCache.unicastExecutor.execute(new WebsocketMessageRunnable(
				message));
	}
}
